#include "GTransform2.h"

#include "GMath.h"

namespace GMath
{
	void GTransform2::Transform(OUTPUT GRay2& Output, const GRay2& Ray, const GCoordFrame2& Frame)
	{
		Transform(Output, Ray, Frame.GetScale(), Frame.GetRotation(), Frame.GetPosition());
	}

	void GTransform2::Transform(OUTPUT GRay2& Output, const GRay2& Ray, const GVector2& Scale, float Rotation, const GVector2& Translation)
	{
		//!+ YAZILACAK
	}

	void GTransform2::Transform(OUTPUT GCircle& Output, const GCircle& Disk, const GCoordFrame2& Frame)
	{
		Transform(Output, Disk, Frame.GetScale(), Frame.GetRotation(), Frame.GetPosition());
	}

	void GTransform2::Transform(OUTPUT GCircle& Output, const GCircle& Disk, const GVector2& Scale, float Rotation, const GVector2& Translation)
	{
		//!+ YAZILACAK
	}

	void GTransform2::Transform(OUTPUT GTriangle2& Output, const GTriangle2& Triangle, const GCoordFrame2& Frame)
	{
		Transform(Output, Triangle, Frame.GetScale(), Frame.GetRotation(), Frame.GetPosition());
	}

	void GTransform2::Transform(OUTPUT GTriangle2& Output, const GTriangle2& Triangle, const GVector2& Scale, float Rotation, const GVector2& Translation)
	{
		//!+ YAZILACAK
	}

	void GTransform2::Transform(OUTPUT GRectangleAligned& Output, const GRectangleAligned& Rect, const GCoordFrame2& Frame)
	{
		Transform(Output, Rect, Frame.GetScale(), Frame.GetRotation(), Frame.GetPosition());
	}

	void GTransform2::Transform(OUTPUT GRectangleAligned& Output, const GRectangleAligned& Rect, const GVector2& Scale, float Rotation, const GVector2& Translation)
	{
		//!+ YAZILACAK
	}

	void GTransform2::Transform(OUTPUT GRectangleOriented& Output, const GRectangleOriented& Rect, const GCoordFrame2& Frame)
	{
		Transform(Output, Rect, Frame.GetScale(), Frame.GetRotation(), Frame.GetPosition());
	}

	void GTransform2::Transform(OUTPUT GRectangleOriented& Output, const GRectangleOriented& Rect, const GVector2& Scale, float Rotation, const GVector2& Translation)
	{
		//!+ YAZILACAK
	}

	void GTransform2::CreateScale(OUTPUT GMatrix3x3& Output, const GVector2& Scale)
	{
		Output.I11 = Scale.x;
		Output.I12 = 0.0f;
		Output.I13 = 0.0f;
		Output.I21 = 0.0f;
		Output.I22 = Scale.y;
		Output.I23 = 0.0f;
		Output.I31 = 0.0f;
		Output.I32 = 0.0f;
		Output.I33 = 1.0f;
	}

	void GTransform2::CreateRotation(OUTPUT GMatrix3x3& Output, float Value)
	{
		float Sin = SinF(Value);
		float Cos = CosF(Value);

		Output.I11 = Cos;
		Output.I12 =-Sin;
		Output.I13 = 0.0f;
		Output.I21 = Sin;
		Output.I22 = Cos;
		Output.I23 = 0.0f;
		Output.I31 = 0.0f;
		Output.I32 = 0.0f;
		Output.I33 = 1.0f;
	}

	void GTransform2::CreateTranslation(OUTPUT GMatrix3x3& Output, const GVector2& Translation)
	{
		Output.I11 = 1.0f;
		Output.I12 = 0.0f;
		Output.I13 = 0.0f;
		Output.I21 = 0.0f;
		Output.I22 = 1.0f;
		Output.I23 = 0.0f;
		Output.I31 = Translation.x;
		Output.I32 = Translation.y;
		Output.I33 = 1.0f;
	}

	void GTransform2::CreateLocal(OUTPUT GMatrix3x3& Output, const GVector2& Scale, float Rotation, const GVector2 Position)
	{

		float Sin = SinF(Rotation);
		float Cos = CosF(Rotation);
		/*
		Output.I11 = Cos * Scale.x; 
		Output.I12 = -Sin; 
		Output.I13 = Position.x;

		Output.I21 = Sin; 
		Output.I22 = Cos * Scale.y; 
		Output.I23 = Position.y;

		Output.I31 = 0.0f; 
		Output.I32 = 0.0f; 
		Output.I33 = 1.0f;
		*/

		Output.I11 = Cos * Scale.x;
		Output.I12 = -Sin * Scale.x;
		Output.I13 = 0.0f;

		Output.I21 = Sin * Scale.y;
		Output.I22 = Cos * Scale.y;
		Output.I23 = 0.0f;

		Output.I31 = Position.x;
		Output.I32 = Position.y;
		Output.I33 = 1.0f;
	}

	void GTransform2::CreateShear(OUTPUT GMatrix3x3& Output, const GVector2& Shear)
	{
		float TanX = TanF(Shear.x);
		float TanY = TanF(Shear.y);

		Output.I21 = TanX;
		Output.I12 = TanY;
	}

	void GTransform2::CreateReflection(OUTPUT GMatrix3x3& Output, const GVector2& Axis)
	{
		//!+ YAZILACAK
	}

}